
package com.cn.type;

import java.util.HashMap;
import java.util.Map;


/**
 * FUN: 基本类型工厂类
 *
 * @author sushy
 * @time 2016-3-24
 */
public final class TypeFactory {
	private static Map<Class<?>, ITypeConverter> types = new HashMap<Class<?>, ITypeConverter>();

	static {
		// 注册基本类型
		types.put(String.class, new TypeString());
		types.put(Long.class, new TypeLong());
		types.put(long.class, new TypeLong());
		types.put(Integer.class, new TypeInt());
		types.put(int.class, new TypeInt());
		types.put(Short.class, new TypeShort());
		types.put(short.class, new TypeShort());
		types.put(Boolean.class, new TypeBoolean());
		types.put(boolean.class, new TypeBoolean());
		types.put(java.util.Date.class, new TypeDate());
		types.put(java.sql.Timestamp.class, new TypeDate());
		types.put(java.sql.Time.class, new TypeDate());
	}

	public static ITypeConverter getType(Class<?> cls) {
		return (ITypeConverter) types.get(cls);
	}

}
